package model;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class Pagination {
	//页码
	private String page_index = "1";
	//共几页
	private String page_size;
	//每页条数
	private String page_count = "20";
	//查询用 从几到几
	private String page_from = "1";
	private String page_to = "10";
	//总数
	private String total;
	//分页开关 可不用
	private String page_yn = "Y";
	
	private int limit_from = 0;
	private int limit_count = 10;
	
	public void setPagination(String pageIndex, String total){
		if(pageIndex != null && !"".equals(pageIndex)){
			this.page_index = pageIndex;
		}else{
			pageIndex = "1";
			this.page_index = pageIndex;
		}
		this.total = total;
		int pi = Integer.parseInt(pageIndex);
		int tt = Integer.parseInt(total);
		int pc =  Integer.parseInt(page_count);
		this.page_size = (tt%pc==0?tt/pc:(tt/pc+1))  + "";
		this.page_from = ((pi-1)*pc+1)+"";
		this.page_to = ((pi-1)*pc+pc)+"";
		this.limit_from =Integer.parseInt(this.page_from)-1;
		this.limit_count =Integer.parseInt(this.page_count);
	}
	public String getPage_index() {
		return page_index;
	}

	public void setPage_index(String page_index) {
		this.page_index = page_index;
	}
	
	public String getPage_size() {
		return page_size;
	}

	public void setPage_size(String page_size) {
		this.page_size = page_size;
	}
	public String getPage_count() {
		return page_count;
	}

	public void setPage_count(String page_count) {
		this.page_count = page_count;
	}
	@JsonIgnore 
	public String getPage_from() {
		return page_from;
	}

	public void setPage_from(String page_from) {
		this.page_from = page_from;
	}
	@JsonIgnore 
	public String getPage_to() {
		return page_to;
	}

	public void setPage_to(String page_to) {
		this.page_to = page_to;
	}
	public String getTotal() {
		return total;
	}

	public void setTotal(String total) {
		this.total = total;
	}
	@JsonIgnore 
	public String getPage_yn() {
		return page_yn;
	}

	public void setPage_yn(String page_yn) {
		this.page_yn = page_yn;
	}
	@JsonIgnore 
	public int getLimit_from() {
		return limit_from;
	}

	public void setLimit_from(int limit_from) {
		this.limit_from = limit_from;
	}
	@JsonIgnore 
	public int getLimit_count() {
		return limit_count;
	}

	public void setLimit_count(int limit_count) {
		this.limit_count = limit_count;
	}
	
}
